package com.matrix.java.chap_03.example;

import java.util.Scanner;

/**
 * @since 2021-10-22-14:50
 */
public class Case3_05 {

    static double TAXRATE_1 = 0.1;
    static double TAXRATE_2 = 0.15;
    static double TAXRATE_3 = 0.25;
    static double TAXRATE_4 = 0.28;
    static double TAXRATE_5 = 0.33;
    static double TAXRATE_6 = 0.35;

    public static void main(String[] args) {

        System.out.print("输入: ");
        Scanner input = new Scanner(System.in);
        int personType = input.nextInt();
        if (personType < 0 && personType > 4) {
            System.out.println("error");
        } else {
            if (personType == 0) {
                System.out.print("单身,收入: ");
                double income = input.nextDouble();
                if (income < 0) {
                    System.out.println("error1");
                } else if (income <= 8350) {
                    double tax = income * TAXRATE_1;
                    System.out.println("税收: " + tax);
                } else if (income <= 33950) {

                    double tax = 8350 * TAXRATE_1 + (income - 8350) * TAXRATE_2;
                    System.out.println("税收: " + tax);
                } else if (income <= 82250) {

                    double tax = 8350 * TAXRATE_1 + (33950 - 8350) * TAXRATE_2
                            + (income - 33950) * TAXRATE_3;
                    System.out.println("税收: " + tax);
                } else if (income <= 171550) {

                    double tax = 8350 * TAXRATE_1 + (33950 - 8350) * TAXRATE_2
                            + (82250 - 33950) * TAXRATE_3 + (income - 82250) * TAXRATE_4;
                    System.out.println("税收: " + tax);
                } else if (income <= 372950) {

                    double tax = 8350 * TAXRATE_1 + (33950 - 8350) * TAXRATE_2
                            + (82250 - 33950) * TAXRATE_3 + (171550 - 82250) * TAXRATE_4
                            + (income - 171550) * TAXRATE_5;
                    System.out.println("税收: " + tax);
                } else if (income >= 372951) {

                    double tax = 8350 * TAXRATE_1 + (33950 - 8350) * TAXRATE_2
                            + (82250 - 33950) * TAXRATE_3 + (171550 - 82250) * TAXRATE_4
                            + (372950 - 171550) * TAXRATE_5 + (income - 372950) * TAXRATE_6;
                    System.out.println("税收: " + tax);
                }
            } else if (personType == 1) {
                System.out.print("已婚共");
                double income = input.nextDouble();
                if (income < 0) {
                    System.out.println("error1");
                } else if (income >= 0 && income <= 8350) {
                    double TAXRATE_1 = 0.1;
                    double tax = income * TAXRATE_1;
                    System.out.println("税收: " + tax);
                }
            } else if (personType == 2) {

            } else if (personType == 3) {

            }
        }
        input.close();
    }
}
